<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
  <meta charset="utf-8">
  <title></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" th:href="@{static/layuiadmin/layui/css/layui.css}"
    media="all"> <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>

<body>

  <table class="layui-hide" id="test" lay-filter="test"></table>


  <script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit" href="#">答卷</a>
</script>


  <script src="../../layuiadmin/layui/layui.js" th:src="@{static/layuiadmin/layui/layui.js}"></script>
  <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

  <script th:inline="none">
    layui.use('table', function () {
      var table = layui.table;
      var $ = layui.$;
      $.ajax({
        url: "/showBoughtPapers",
        type: "POST",
        dataType: "json",
        success: function (data) {
          //console.log(JSON.stringify(data))
          table.render({
            elem: '#test',
            data: data
            , toolbar: '#toolbarDemo'
            , title: '用户数据表'
            , cols: [[
              { field: 'trade_id', title: '交易ID', fixed: 'left', unresize: true, sort: true }
              , { field: 'paper_name', title: '试卷名称', }
              , { field: 'time', title: '交易时间',  sort: true }
              , { field: 'paper_type', title: '试卷类型'}

              , { field: 'seller_id', title: '出售者'}
              , { field: 'points', title: '积分' }
              , { field: 'paper_id', title: '卷子id', hide: true }
              , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 80 }
            ]]
            , page: true
            ,done: function(res, curr, count){
              console.log(JSON.stringify(res.data));
              for(var i=0;i<res.data.length;i++){
                
              }
            }
    
            
          });


          //监听行工具事件
          table.on('tool(test)', function (obj) {
            var data = obj.data;
            console.log(data)
            obj.update({
              time:1
            })
            //console.log(obj)
            if (obj.event === 'edit') {

          
            }
          });
        }
      })


    });
  </script>

</body>

</html>